#ifndef	__BFX_REFXMLQUALIFIEDNAME_H__
#define	__BFX_REFXMLQUALIFIEDNAME_H__

namespace BFX
{
//////////////////////////////////////////////////////////////////////////////
// REFXMLQualifiedName declaration.

class REFXMLQualifiedName : public REFObject
{
public:
	// Initializes a new instance with specified name and namespace.
	REFXMLQualifiedName(const UniString& strName = UniString(), const UniString& strNamespace = UniString());
	virtual ~REFXMLQualifiedName();

	bool IsEmpty() const;
	UniString GetName() const;
	UniString GetNamespace() const;

	bool Equals(REFXMLQualifiedName* pOther) const;
	UniString ToString() const;

private:
	UniString	m_strName;
	UniString	m_strNamespace;
};

//////////////////////////////////////////////////////////////////////////////
// REFXMLQualifiedName inline methods.

inline REFXMLQualifiedName::REFXMLQualifiedName(const UniString& strName, const UniString& strNamespace)
{
	m_strName = strName;
	m_strNamespace = strNamespace;
}
inline REFXMLQualifiedName::~REFXMLQualifiedName()
{
}

inline bool REFXMLQualifiedName::IsEmpty() const
{
	return (m_strName.IsEmpty() && m_strNamespace.IsEmpty());
}
inline UniString REFXMLQualifiedName::GetName() const
{
	return m_strName;
}
inline UniString REFXMLQualifiedName::GetNamespace() const
{
	return m_strNamespace;
}

inline bool REFXMLQualifiedName::Equals(REFXMLQualifiedName* target) const
{
	if (this == target)
		return true;
	if (target == NULL)
		return false;
	return (GetName() == target->GetName() && GetNamespace() == target->GetNamespace());
}

inline UniString REFXMLQualifiedName::ToString() const
{
	return (GetNamespace().IsEmpty() ? GetName() : GetNamespace() + USTR(":") + GetName());
}

//////////////////////////////////////////////////////////////////////////////
// Special versions of HashTraits for REF<REFXMLQualifiedName>.
template<>
class HashTraits<REF<REFXMLQualifiedName> >
{
public:
	static int __cdecl GetHashCode(REFXMLQualifiedName* pQName) throw()
	{
		typedef HashTraits<UniString> StrHashTraits;
		if (pQName == NULL)
			return 0;	// NOTE: NULL value is also allowed.
		return StrHashTraits::GetHashCode(pQName->GetName()) + StrHashTraits::GetHashCode(pQName->GetNamespace());
	}
	static bool __cdecl Equals(REFXMLQualifiedName* pQName1, REFXMLQualifiedName* pQName2) throw()
	{
		if (pQName1 == NULL || pQName2 == NULL)
			return pQName1 == pQName2;
		return pQName1->Equals(pQName2);
	}
};

}	//	namespace BFX

#endif	//	__BFX_REFXMLQUALIFIEDNAME_H__
